package com.letv.core.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * 本地视频信息ITEM
 * 
 * @author sumin.zhao
 * 
 */
public class DownloadLocalVideoItemBean implements Parcelable {
    private String title = ""; // 视频名称，截取最后一个“/”后的内容
    private String path = ""; // 视频的绝对路径
    private String video_W_H = ""; // 视频分辨率
    private String videoType = ""; // 视频类型
    private long fileSize = 0; // 文件大小“0.00M”
    private long fileDuration = 0; // 视频时长
    private long position = -1000l; // 视频播放进度，时间戳

    private long fileDate = 0l; // 视频创建时间,时间戳

    /**
     * 获得视频分辨率
     * 
     * @return
     */
    public String getVideo_W_H() {
        return video_W_H;
    }

    /**
     * 设置视频分辨率
     * 
     * @param video_W_H
     */
    public void setVideo_W_H(String video_W_H) {
        this.video_W_H = video_W_H;
    }

    /**
     * 获得视频类型，mp4,avi,rm,rmvb...
     * 
     * @return
     */
    public String getVideoType() {
        return videoType;
    }

    /**
     * 设置视频类型，mp4,avi,rm,rmvb...
     * 
     * @param videoType
     */
    public void setVideoType(String videoType) {
        this.videoType = videoType;
    }

    /**
     * 得到视频名称，从file.getFileName()中得到
     * 
     * @return
     */
    public String getTitle() {
        return title;
    }

    /**
     * 设置视频名称，从file.getFileName()中得到
     * 
     * @param title
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * 获得视频的绝对路径
     * 
     * @return
     */
    public String getPath() {
        return path;
    }

    /**
     * 设置视频的绝对路径
     * 
     * @param path
     */
    public void setPath(String path) {
        this.path = path;
    }

    /**
     * 得到视频文件的长度，单位byte
     * 
     * @return
     */
    public long getFileSize() {
        return fileSize;
    }

    /**
     * 视频文件的长度，单位byte
     * 
     * @param fileSize
     */
    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    /**
     * 得到视频的总时长，时间戳
     * 
     * @return
     */
    public long getFileDuration() {
        return fileDuration;
    }

    /**
     * 视频的总时长，时间戳
     * 
     * @param fileDuration
     */
    public void setFileDuration(long fileDuration) {
        this.fileDuration = fileDuration;
    }

    /**
     * 得到视频的创建时间，时间戳
     * 
     * @return
     */
    public long getFileDate() {
        return fileDate;
    }

    /**
     * 视频的创建时间，时间戳
     * 
     * @param fileDate
     */
    public void setFileDate(long fileDate) {
        this.fileDate = fileDate;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(title);
        out.writeString(path);
        out.writeString(video_W_H);
        out.writeString(videoType);
        out.writeLong(fileSize);
        out.writeLong(fileDuration);
        out.writeLong(position);
        out.writeLong(fileDate);
    }

    public DownloadLocalVideoItemBean() {
    }

    public DownloadLocalVideoItemBean(Parcel in) {
        title = in.readString();
        path = in.readString();
        video_W_H = in.readString();
        videoType = in.readString();
        fileSize = in.readLong();
        fileDuration = in.readLong();
        position = in.readLong();
        fileDate = in.readLong();
    }

    /**
     * 得到当前视频播放记录的位置，时间戳
     * 
     * @return
     */
    public long getPosition() {
        return position;
    }

    /**
     * 当前视频播放记录的位置，时间戳
     * 
     * @param position
     */
    public void setPosition(long position) {
        this.position = position;
    }

    public static DownloadLocalVideoItemBean.Creator<DownloadLocalVideoItemBean> CREATOR = new Parcelable.Creator<DownloadLocalVideoItemBean>() {

        @Override
        public DownloadLocalVideoItemBean createFromParcel(Parcel in) {

            return new DownloadLocalVideoItemBean(in);
        }

        @Override
        public DownloadLocalVideoItemBean[] newArray(int size) {

            return new DownloadLocalVideoItemBean[size];
        }
    };

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((title == null) ? 0 : title.hashCode());
        result = prime * result + ((path == null) ? 0 : path.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;

        DownloadLocalVideoItemBean other = (DownloadLocalVideoItemBean) obj;

        if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(other.title)) {
            if (!title.equals(other.title)) {
                return false;
            }
        }

        if (!TextUtils.isEmpty(path) && !TextUtils.isEmpty(other.path)) {
            if (!path.equals(other.path)) {
                return false;
            }
        }

        return true;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "LocalVideoItem [title=" + title + ", path=" + path + ", video_W_H=" + video_W_H + ", videoType="
                + videoType + ", fileSize=" + fileSize + ", fileDuration=" + fileDuration + ", position=" + position
                + ", fileDate=" + fileDate + "]";
    }

}
